package 集合框架.PriorityQueue源码解析;

import java.util.PriorityQueue;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2022-01-05 18:24
 **/
public class TestPriorityQueue {

    public static void main(String[] args) {

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.add(3);
        priorityQueue.add(5);
        priorityQueue.add(11);
        priorityQueue.add(50);
        priorityQueue.add(51);
        priorityQueue.add(15);
        priorityQueue.add(11);
        priorityQueue.add(52);
        priorityQueue.add(53);
        priorityQueue.add(54);
        priorityQueue.add(55);
        priorityQueue.add(16);
        priorityQueue.add(19);
        priorityQueue.add(12);
        priorityQueue.add(16);
        int level = Math.log(priorityQueue.size() + 1)/Math.log(2) == (int)(Math.log(priorityQueue.size() + 1)/Math.log(2))
                ? (int)(Math.log(priorityQueue.size() + 1)/Math.log(2)) : (int)(Math.log(priorityQueue.size() + 1)/Math.log(2)) + 1;
//        System.out.println(level);
        priorityQueue.forEach(System.out::println);

        System.out.println("===========");
        priorityQueue.remove(5);
        priorityQueue.forEach(System.out::println);
    }
}
